package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.GkZytb;
import cn.source.system.service.IGkZytbService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 志愿填报主Controller
 *
 * @author sourcebyte.vip
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/system/gkZytb")
public class GkZytbController extends BaseController
{
    @Autowired
    private IGkZytbService gkZytbService;

    /**
     * 查询志愿填报主列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytb:list')")
    @GetMapping("/list")
    public TableDataInfo list(GkZytb gkZytb)
    {
        startPage();
        List<GkZytb> list = gkZytbService.selectGkZytbList(gkZytb);
        return getDataTable(list);
    }

    /**
     * 获取志愿填报主详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(gkZytbService.selectGkZytbById(id));
    }

    /**
     * 新增志愿填报主
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytb:add')")
    @Log(title = "志愿填报主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GkZytb gkZytb)
    {
        return toAjax(gkZytbService.insertGkZytb(gkZytb));
    }

    /**
     * 修改志愿填报主
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytb:edit')")
    @Log(title = "志愿填报主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GkZytb gkZytb)
    {
        return toAjax(gkZytbService.updateGkZytb(gkZytb));
    }

    /**
     * 删除志愿填报主
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytb:remove')")
    @Log(title = "志愿填报主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gkZytbService.deleteGkZytbByIds(ids));
    }

    /**
     * 导出志愿填报主列表
     */
    @PreAuthorize("@ss.hasPermi('system:gkZytb:export')")
    @Log(title = "志愿填报主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GkZytb gkZytb)
    {
        List<GkZytb> list = gkZytbService.selectGkZytbList(gkZytb);
        ExcelUtil<GkZytb> util = new ExcelUtil<GkZytb>(GkZytb.class);
        util.exportExcel(response, list, "志愿填报主数据");
    }
}
